/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DialogPeminjamanDetail.java
 *
 * Created on 09 Des 12, 11:52:01
 */
package sistemperpustakaan.view.transaksi;

import com.toedter.calendar.JDateChooser;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
import sistemperpustakaan.controller.TransaksiController;
import sistemperpustakaan.entity.TransaksiDetailView;
import sistemperpustakaan.entity.TransaksiView;
import sistemperpustakaan.model.UserModel;
import sistemperpustakaan.tablemodel.TransaksiDetailTableModel;
import sistemperpustakaan.utility.DateUtility;
import sistemperpustakaan.utility.UserUtility;

/**
 *
 * @author EKo
 */
public class DialogTransaksiDetail extends javax.swing.JDialog implements ListSelectionListener {

    TransaksiController controller;
    TransaksiDetailTableModel tableModel;
    boolean isNew = false;
    TransaksiView transaksi;
    DefaultTableCellRenderer centerCellRenderer = new DefaultTableCellRenderer();
    DefaultTableCellRenderer rightCellRenderer = new DefaultTableCellRenderer();
    DateUtility du = new DateUtility();
    String idUser = UserUtility.idUser;
    String namaUser = UserUtility.name;

    /**
     * Creates new form DialogPeminjamanDetail
     */
    public DialogTransaksiDetail(java.awt.Frame parent, boolean modal, TransaksiController controller) {
        super(parent, modal);
        initComponents();
        setSize(800, 600);
        setLocationRelativeTo(parent);
        this.controller = controller;
        this.controller.setTransaksiDetail(this);
        tableModel = new TransaksiDetailTableModel();
        tableModel.setListDetailTransaksi(new ArrayList<TransaksiDetailView>());
        tblTransaksiDetail.setModel(tableModel);
        tblTransaksiDetail.getSelectionModel().addListSelectionListener(this);
        txtUser.setText(idUser);
        txtPetugas.setText(namaUser);
        setTitle("Tambah Data");
        SetAction();
        setButton();
        setTableWidth();
        isNew = true;
        buttonSave.setEnabled(UserUtility.privilege[UserUtility.INSERT_UPDATE_DELETE]);
//        controller.deleteAllPinjamSementara();
    }

    DialogTransaksiDetail(java.awt.Frame parent, boolean modal, TransaksiController controller, int noPinjam) {
        super(parent, modal);
        initComponents();
        setSize(800, 600);
        this.controller = controller;
        this.controller.setTransaksiDetail(this);
        tblTransaksiDetail.getSelectionModel().addListSelectionListener(this);
        isNew = false;
        setButton();
        setLocationRelativeTo(parent);
        controller.showDataTransaksi(noPinjam);
        controller.findDataTransaksiDetail(noPinjam);
        setTableWidth();
        setTitle("Edit Data");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        txtTanggalPinjam.setDate(date);
//        txtTanggalKembali.setDate(date);
        //SetAction();
        buttonSave.setEnabled(UserUtility.privilege[UserUtility.INSERT_UPDATE_DELETE]);
        btnTambah.setEnabled(false);
        btnHapus.setEnabled(false);
        buttonSelectAnggota.setEnabled(false);
        txtIdAnggota.setEnabled(false);
//        controller.deleteAllPinjamSementara();
    }

    public JTextField getTxtPetugas() {
        return txtPetugas;
    }

    public void setTxtPetugas(JTextField txtPetugas) {
        this.txtPetugas = txtPetugas;
    }

    public TransaksiDetailTableModel getTableModel() {
        return tableModel;
    }

    public void setTableModel(TransaksiDetailTableModel tableModel) {
        this.tableModel = tableModel;
    }

    public JTextField getTxtDenda() {
        return txtDenda;
    }

    public void setTxtDenda(JTextField txtDenda) {
        this.txtDenda = txtDenda;
    }

    public JTextField getTxtIdAnggota() {
        return txtIdAnggota;
    }

    public void setTxtIdAnggota(JTextField txtIdAnggota) {
        this.txtIdAnggota = txtIdAnggota;
    }

    public JTextField getTxtIdInventaris() {
        return txtIdInventaris;
    }

    public void setTxtIdInventaris(JTextField txtIdInventaris) {
        this.txtIdInventaris = txtIdInventaris;
    }

    public JTextField getTxtIdTransaksi() {
        return txtIdTransaksi;
    }

    public void setTxtIdTransaksi(JTextField txtIdTransaksi) {
        this.txtIdTransaksi = txtIdTransaksi;
    }

    public JTextField getTxtIdTransaksiDetail() {
        return txtIdTransaksiDetail;
    }

    public void setTxtIdTransaksiDetail(JTextField txtIdTransaksiDetail) {
        this.txtIdTransaksiDetail = txtIdTransaksiDetail;
    }

    public JTextField getTxtJudul() {
        return txtJudul;
    }

    public void setTxtJudul(JTextField txtJudul) {
        this.txtJudul = txtJudul;
    }

    public JTextField getTxtNama() {
        return txtNama;
    }

    public void setTxtNama(JTextField txtNama) {
        this.txtNama = txtNama;
    }

    public JTextField getTxtNis() {
        return txtNis;
    }

    public void setTxtNis(JTextField txtNis) {
        this.txtNis = txtNis;
    }

    public JDateChooser getTxtTanggalKembali() {
        return txtTanggalKembali;
    }

    public void setTxtTanggalKembali(JDateChooser txtTanggalKembali) {
        this.txtTanggalKembali = txtTanggalKembali;
    }

    public JDateChooser getTxtTanggalPinjam() {
        return txtTanggalPinjam;
    }

    public void setTxtTanggalPinjam(JDateChooser txtTanggalPinjam) {
        this.txtTanggalPinjam = txtTanggalPinjam;
    }

    public JTextField getTxtTerlambat() {
        return txtTerlambat;
    }

    public void setTxtTerlambat(JTextField txtTerlambat) {
        this.txtTerlambat = txtTerlambat;
    }

    public JTextField getTxtUser() {
        return txtUser;
    }

    public void setTxtUser(JTextField txtUser) {
        this.txtUser = txtUser;
    }

    public JTable getTblTransaksiDetail() {
        return tblTransaksiDetail;
    }

    public void setTblTransaksiDetail(JTable tblTransaksiDetail) {
        this.tblTransaksiDetail = tblTransaksiDetail;
    }

    public final void setButton() {
        buttonSelectAnggota.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                SelectAnggota sa = new SelectAnggota(controller.getFrmTransaksiView().getFrameMain(), true, controller);
                Point p = txtIdAnggota.getLocationOnScreen();
                p.setLocation(p.getX(), p.getY() + 28);
                sa.setLocation(p);
                sa.setVisible(true);
            }
        });
        buttonSelectInventaris.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                SelectInventaris si = new SelectInventaris(controller.getFrmTransaksiView().getFrameMain(), true, controller);
                Point p = txtIdInventaris.getLocationOnScreen();
                p.setLocation(p.getX(), p.getY() + 28);
                si.setLocation(p);
                si.setVisible(true);
            }
        });
        btnTambah.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                controller.addPinjamBuku();
            }
        });
        btnHapus.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                controller.removeBuku();
            }
        });
        btnKembalikan.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                controller.returnBuku();
            }
        });

        buttonCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });
        buttonSave.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (isNew) {
                    controller.saveNewTransaksi();
                } else {
                    controller.saveUpdateTransaksi();
                }
            }
        });
    }

    public final void setTableWidth() {
        int[] width = {80, 100, 200, 120, 120, 100, 100, 100};
        for (int i = 0; i < 7; i++) {
            tblTransaksiDetail.getColumnModel().getColumn(i).setPreferredWidth(width[i]);
        }
        centerCellRenderer.setHorizontalAlignment(JLabel.CENTER);
        rightCellRenderer.setHorizontalAlignment(JLabel.RIGHT);
    }

    private void SetAction() {
//        controller.showGenerateIdTransaksi();
        //controller.showGenerateIdTransaksiDetail();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        txtTanggalPinjam.setDate(date);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        txtIdTransaksi = new javax.swing.JTextField();
        txtIdAnggota = new javax.swing.JTextField();
        txtNis = new javax.swing.JTextField();
        txtNama = new javax.swing.JTextField();
        txtUser = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        buttonSelectAnggota = new javax.swing.JButton();
        txtPetugas = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        txtIdTransaksiDetail = new javax.swing.JTextField();
        txtIdInventaris = new javax.swing.JTextField();
        txtJudul = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtTanggalPinjam = new com.toedter.calendar.JDateChooser();
        txtTanggalKembali = new com.toedter.calendar.JDateChooser();
        txtTerlambat = new javax.swing.JTextField();
        txtDenda = new javax.swing.JTextField();
        btnTambah = new javax.swing.JButton();
        btnHapus = new javax.swing.JButton();
        btnKembalikan = new javax.swing.JButton();
        buttonSelectInventaris = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblTransaksiDetail = new javax.swing.JTable();
        jLabel16 = new javax.swing.JLabel();
        buttonSave = new javax.swing.JButton();
        buttonCancel = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        gbr = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jTabbedPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        jPanel1.add(txtIdTransaksi, new org.netbeans.lib.awtextra.AbsoluteConstraints(141, 46, 104, -1));
        jPanel1.add(txtIdAnggota, new org.netbeans.lib.awtextra.AbsoluteConstraints(141, 85, 185, -1));

        txtNis.setEditable(false);
        jPanel1.add(txtNis, new org.netbeans.lib.awtextra.AbsoluteConstraints(141, 127, 185, -1));

        txtNama.setEditable(false);
        jPanel1.add(txtNama, new org.netbeans.lib.awtextra.AbsoluteConstraints(141, 166, 185, -1));

        txtUser.setEditable(false);
        jPanel1.add(txtUser, new org.netbeans.lib.awtextra.AbsoluteConstraints(141, 203, 50, -1));

        jLabel1.setText("ID Transaksi");
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(41, 49, -1, -1));

        jLabel2.setText("ID Anggota");
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(41, 88, -1, -1));

        jLabel3.setText("NIS / NIK");
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(41, 127, -1, -1));

        jLabel4.setText("Nama");
        jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(41, 169, -1, -1));

        jLabel5.setText("Petugas");
        jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(41, 206, -1, -1));

        buttonSelectAnggota.setText("...");
        jPanel1.add(buttonSelectAnggota, new org.netbeans.lib.awtextra.AbsoluteConstraints(336, 84, -1, -1));

        txtPetugas.setEditable(false);
        jPanel1.add(txtPetugas, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 203, 210, -1));

        jLabel17.setForeground(new java.awt.Color(51, 51, 255));
        jLabel17.setText("*tidak perlu diisi");
        jPanel1.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 50, -1, -1));

        jTabbedPane1.addTab("          Transaksi          ", jPanel1);

        txtIdTransaksiDetail.setEditable(false);

        jLabel6.setText("No Detail");

        jLabel7.setText("ID Inventaris");

        jLabel8.setText("Judul");

        txtTanggalPinjam.setDateFormatString("dd MMMM yyyy");

        txtTanggalKembali.setDateFormatString("dd MMMM yyyy");

        btnTambah.setText("TAMBAH");

        btnHapus.setText("HAPUS");

        btnKembalikan.setText("KEMBALIKAN");

        buttonSelectInventaris.setText("...");

        jLabel9.setText("Tanggal pinjam");

        jLabel10.setText("Tanggal kembali");

        jLabel11.setText("Terlambat");

        jLabel12.setText("Hari");

        jLabel13.setText("Denda");

        jLabel14.setText("Rp.");

        tblTransaksiDetail.setAutoCreateRowSorter(true);
        tblTransaksiDetail.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblTransaksiDetail.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane1.setViewportView(tblTransaksiDetail);

        jLabel16.setForeground(new java.awt.Color(51, 51, 255));
        jLabel16.setText("*tidak perlu diisi");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(99, 99, 99)
                        .addComponent(btnTambah, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(btnHapus, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(btnKembalikan))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel11)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(txtIdTransaksiDetail, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel16))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(txtTerlambat, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel12))
                                    .addComponent(txtTanggalPinjam, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                        .addComponent(jLabel13)
                                        .addGap(36, 36, 36)
                                        .addComponent(jLabel14)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtDenda, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(jLabel10)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txtTanggalKembali, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(txtIdInventaris, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(buttonSelectInventaris, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(txtJudul, javax.swing.GroupLayout.PREFERRED_SIZE, 585, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIdTransaksiDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(jLabel6))
                .addGap(31, 31, 31)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtIdInventaris, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(buttonSelectInventaris))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtJudul, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(39, 39, 39)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel9)
                    .addComponent(txtTanggalPinjam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(txtTanggalKembali, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtTerlambat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14)
                    .addComponent(txtDenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnTambah)
                    .addComponent(btnHapus)
                    .addComponent(btnKembalikan))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("          Transaksi Detail          ", jPanel2);

        getContentPane().add(jTabbedPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 83, 750, 420));

        buttonSave.setText("Save");
        getContentPane().add(buttonSave, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 510, 83, -1));

        buttonCancel.setText("Cancel");
        getContentPane().add(buttonCancel, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 510, 83, -1));

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel15.setText("Data Detail Transaksi Perpustakaan");

        gbr.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        gbr.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sistemperpustakaan/image/transaksi.png"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(gbr, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(164, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(gbr, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(jLabel15)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnHapus;
    private javax.swing.JButton btnKembalikan;
    private javax.swing.JButton btnTambah;
    private javax.swing.JButton buttonCancel;
    private javax.swing.JButton buttonSave;
    private javax.swing.JButton buttonSelectAnggota;
    private javax.swing.JButton buttonSelectInventaris;
    private javax.swing.JLabel gbr;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable tblTransaksiDetail;
    private javax.swing.JTextField txtDenda;
    private javax.swing.JTextField txtIdAnggota;
    private javax.swing.JTextField txtIdInventaris;
    private javax.swing.JTextField txtIdTransaksi;
    private javax.swing.JTextField txtIdTransaksiDetail;
    private javax.swing.JTextField txtJudul;
    private javax.swing.JTextField txtNama;
    private javax.swing.JTextField txtNis;
    private javax.swing.JTextField txtPetugas;
    private com.toedter.calendar.JDateChooser txtTanggalKembali;
    private com.toedter.calendar.JDateChooser txtTanggalPinjam;
    private javax.swing.JTextField txtTerlambat;
    private javax.swing.JTextField txtUser;
    // End of variables declaration//GEN-END:variables

    public void valueChanged(ListSelectionEvent e) {
        try {
            txtDenda.setText("");
            txtIdInventaris.setText("");
            txtJudul.setText("");
            txtTanggalKembali.setDate(null);
            int r = tblTransaksiDetail.getSelectedRow();
            if (r > -1) {
                controller.showSelectedData(r);
            }
        } catch (Exception ex) {
        }
    }
}
